package com.credithc.signature.common.service;

import com.credithc.signature.common.mapper.SignatureLogExtMapper;
import com.credithc.signature.common.po.SignatureLogExt;
import com.credithc.signature.common.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;

@Service
public class SignatureLogExtService {

    @Autowired
    private SignatureLogExtMapper signatureLogExtMapper;


    public int insert(SignatureLogExt signatureLogExt) {
        return signatureLogExtMapper.insert(signatureLogExt);
    }


    public int insertSelective(SignatureLogExt signatureLogExt) {
        return signatureLogExtMapper.insertSelective(signatureLogExt);
    }

    public int insertList(List<SignatureLogExt> signatureLogExts) {
        return signatureLogExtMapper.insertList(signatureLogExts);
    }


    public int updateByPrimaryKeySelective(SignatureLogExt signatureLogExt) {
        return signatureLogExtMapper.updateByPrimaryKeySelective(signatureLogExt);
    }

    /**
     * 根据ID获取数据
     *
     * @param id
     * @return
     */
    public SignatureLogExt selectOneById(Long id, String date) {
        Date startTime = DateUtil.getTodayStartTime(date);
        Date lastTime = DateUtil.getTodayLastTime(date);
        Example example = new Example(SignatureLogExt.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andBetween("createTime", startTime, lastTime);
        criteria.andEqualTo("id", id);
        SignatureLogExt signatureLogExt = signatureLogExtMapper.selectOneByExample(example);
        return signatureLogExt;
    }
}
